package org.example.position.controller;

import org.example.position.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
public class PositionController {

    @Autowired
    private PositionService positionService;

    @GetMapping("/importToEs")
    public String importToEs(){
        positionService.importToEs();
        return "ok";
    }

    @GetMapping("/searchPos")
    public List<Map<String, Object>> searchPos(@RequestParam String keyword) throws IOException {
        List<Map<String, Object>> maps = positionService.searchPos(keyword);
        return maps;
    }

}
